package com.lagou.ipersistence.builder;

import com.lagou.ipersistence.mapping.BoundSql;
import com.lagou.ipersistence.mapping.ParameterMapping;
import com.lagou.ipersistence.mapping.SqlSource;
import com.lagou.ipersistence.session.Configuration;

import java.util.List;

/**
 * 静态的SqlSource实现类型
 *
 * @author Yan Jiahong
 * Created on 2020/11/16
 */
public class StaticSqlSource implements SqlSource {
    private final String sql;
    private final List<ParameterMapping> parameterMappings;
    private final Configuration configuration;

    public StaticSqlSource(Configuration configuration, String sql) {
        this(configuration, sql, null);
    }

    public StaticSqlSource(Configuration configuration, String sql, List<ParameterMapping> parameterMappings) {
        this.sql = sql;
        this.parameterMappings = parameterMappings;
        this.configuration = configuration;
    }

    @Override
    public BoundSql getBoundSql(Object parameterObject) {
        return new BoundSql(sql, parameterMappings, parameterObject);
    }
}
